/*es6的使用教程，代码不是顺序执行的*/
/*let定义的是变量，const定义常量，不可修改*/
/*模板字符串*/
let  name = 'lzy';
 conrse = 'welcome to react app ';
console.log(`hello ${name},course is ${conrse}`);/*反引号再 esc下面的`和美元符号包含变量，反引号直接支持空格换行*/
//普通函数写法
{
    function hello(name = 'reactLzy') {
        console.log(`name is ${name}`)
    }
    console.log(hello())
}
//箭头函数写法
const newHello = (name) =>{/*括号内是参数，当参数值只有一个的时候，可以省略括号*/
    console.log(`name is ${name}`)
}
hello('reactApp')
newHello('new name is newReactApp')

setTimeout(()=>{
    console.log('箭头函数的使用方式')
},1000)

const justOneReturn  =  x =>x*2;/*只有一个return语句的时候可以这么用，其实就是省略了中括号*/
console.log(justOneReturn(5))

const defValue = (name = 'LZY') =>{/*如果调用他的人没有传值，则使用默认值*/
    console.log(`hello, ${name}`)
}
console.log(defValue())


{
    let arr = ['lzy','542085432']
    function returnArr(name,QQ) {
        console.log(name,QQ)
    }
    returnArr(...arr) //函数的展开符
}
{
    const obj = {name: 'lzy', QQ: '542085432'}
    console.log(Object.keys(obj))
}
/*对象的任意扩展*/
const obj = {name:'lzy',age:'16'}
const obj2 = {type:'本科',ZY:'netWork'}
console.log({...obj,...obj2,date:'2017'})

//解构赋值,对象也可以
const arr = ['hello','name']
let [arr1,arr2] = arr
console.log(arr1,arr2)
{
    const objOne = {name: 'wangjing', age: '24'}
    const {name, age} = objOne
    /*console.log(name, '|', age)*/
    console.log({...objOne})
}

/*react对class的支持*/
class App{
    constructor(){
        this.name = 'lzy'
    }
    sayHello(){
        console.log(`name is ${this.name}`)
    };
}
app = new App();
app.sayHello()